﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site2.Master" AutoEventWireup="true" CodeBehind="StockVMS.aspx.cs" Inherits="CROSLAND.WebApp.StockVMS" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<%@ Register assembly="IdeaSparx.CoolControls.Web" namespace="IdeaSparx.CoolControls.Web" tagprefix="cc2" %>

<asp:Content ID="Content7" ContentPlaceHolderID="cphMainLeft" runat="server">

    Seleccione una Jerarquía:
    
<div style="height:10px"></div>

    <div id="jerarquiaDIV">
      <asp:TreeView ID="tvJerarquia" runat="server" NodeIndent="10" OnSelectedNodeChanged="tvJerarquia_SelectedNodeChanged"
                    ExpandDepth="1" OnTreeNodePopulate="tvJerarquia_TreeNodePopulate" >
        <SelectedNodeStyle Font-Underline="False" ForeColor="White" BackColor="ActiveCaption" />
        <NodeStyle Font-Names="Verdana" Font-Size="8pt" NodeSpacing="0px" HorizontalPadding="5px" />
      </asp:TreeView>
    </div>


</asp:Content>
<asp:Content ID="Content8" ContentPlaceHolderID="cphMainBody" runat="server">

    <script type="text/javascript">
        var TotalChkBx;
        var Counter;

        window.onload = function () {
            TotalChkBx = parseInt('<%= this.gvListado.Rows.Count %>');
            Counter = 0;
        }

        function HeaderClick(CheckBox) {
            var TargetBaseControl = document.getElementById('<%= this.gvListado.ClientID %>');
            var TargetChildControl = "cbSelect";
            var Inputs = TargetBaseControl.getElementsByTagName("input");
            for (var n = 0; n < Inputs.length; ++n)
                if (Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(TargetChildControl, 0) >= 0)
                    Inputs[n].checked = CheckBox.checked;
            Counter = CheckBox.checked ? TotalChkBx : 0;
        }

        function ChildClick(CheckBox, HCheckBox) {
            var HeaderCheckBox = document.getElementById(HCheckBox);
            if (CheckBox.checked && Counter < TotalChkBx) Counter++;
            else if (Counter > 0) Counter--;
            if (Counter < TotalChkBx) HeaderCheckBox.checked = false;
            else if (Counter == TotalChkBx) HeaderCheckBox.checked = true;
        }

        function getCodigo(source, eventArgs) {
            $get('<%= txtCodCliente.ClientID %>').value = eventArgs.get_value();
        }

        function CerrarDialogo() {
            $find("mpeReserva").hide();
        }

        function CerrarDialogoCampania() {
            $find("mpeCampania").hide();
        }

        function CerrarDialogoPedido() {
            $find('mpePedido').hide();
        }

    </script>

<!-- Llenar en contenido de la derecha -->

   <div style="padding:10px"> 
       
       <asp:Panel runat="server" ID="pnlBusqueda">            
            <table width="100%">
                <tr>
                    <td>Material:</td>
                    <td>
                        <asp:TextBox ID="txtMaterial" runat="server" Width="120"></asp:TextBox>
                    </td>
                    <td>Color:</td>
                    <td>
                        <asp:DropDownList ID="cmbColor" runat="server" Width="130px" />
                    </td>
                    <td>Lote:</td>
                    <td>
                         <asp:TextBox ID="txtLote" runat="server" Width="120"></asp:TextBox>
                    </td>
                </tr>    
                <tr>
                    <td>Disponibilidad:</td>
                    <td>
                        <asp:DropDownList ID="cmbDispo" runat="server" Width="130px" />
                    </td>
                    <td>Grupo de Art.:</td>
                    <td>
                        <asp:DropDownList ID="cmbGrpArt" runat="server" Width="130px" />
                    </td>
                    <td>Año de Fab.:</td>
                    <td>
                         <asp:TextBox ID="txtAnioFabricacion" runat="server" Width="120"></asp:TextBox>
                    </td>
                </tr> 
                 <tr>                 
                    <td colspan="6" style="text-align:center">
                        <asp:Button ID="btnBuscar" OnClick="btnBuscar_Click" runat="server" Text="Buscar" />
                    </td>                    
                </tr>          
            </table>      
       </asp:Panel>
       
     
      
       <div style="float:right; width:400px; text-align: right">
           <asp:Button ID="btnCrearPedido" runat="server" Text="Crear Pedido" onclick="btnCrearPedido_Click" />
           <asp:Button ID="btnCampania" runat="server" Text="Asignar Campaña" onclick="btnCampania_Click" />
           <asp:Button ID="btnReserva" runat="server" Text="Reservar" onclick="btnReserva_Click" />
       </div>
       <div style="clear:both"></div>
       
       <cc2:CoolGridView ID="gvListado" runat="server" Width="100%" Height="350px" 
           AllowPaging="true" PageSize="60"                         
                        CssClass="tbl-materiales" AutoGenerateColumns="false" 
            Font-Size="12px" onpageindexchanging="gvListado_PageIndexChanging">      
            <Columns>            
                 <asp:TemplateField HeaderText="">
                     <itemtemplate>
                         <asp:CheckBox ID="cbSelect" runat="server" />
                         <asp:Label id="lblCodigo" Visible="false" runat="server" Text='<%# Bind("codMaterial") %>'></asp:Label>
                         <asp:Label id="lblLote" Visible="false" runat="server" Text='<%# Bind("lote") %>'></asp:Label>
                      </itemtemplate>           
                      <HeaderTemplate>
                         <asp:CheckBox ID="cbHeaderSelect" runat="server" onclick="javascript:HeaderClick(this);" />
                      </HeaderTemplate> 
                      <ItemStyle HorizontalAlign="Center" />                
                 </asp:TemplateField>            
                 <asp:BoundField DataField="codMaterial" HeaderText="Material"></asp:BoundField> 
                 <asp:BoundField DataField="descMaterial" HeaderText="Descripción" HeaderStyle-Width="250" >
                    <HeaderStyle Width="250px" /></asp:BoundField> 
                 <asp:BoundField DataField="lote" HeaderText="Lote" ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="añoFab" HeaderText="Año Fab." ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="añoModelo" HeaderText="Año Mod." ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="campaña" HeaderText="Campaña" ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="descColor" HeaderText="Color" ItemStyle-HorizontalAlign="Center" ></asp:BoundField> 
                 <asp:BoundField DataField="descCentro" HeaderText="Centro" ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="descAlmacen" HeaderText="Almacén" ItemStyle-HorizontalAlign="Center"></asp:BoundField>              
                 <asp:BoundField DataField="disponibilidad" HeaderText="Disponibilidad" ItemStyle-HorizontalAlign="Center"></asp:BoundField>      
                 <asp:BoundField DataField="codCliente" HeaderText="Código" ItemStyle-HorizontalAlign="Center"></asp:BoundField>                                                                                                     
                 <asp:BoundField DataField="descCliente" HeaderText="Cliente" ItemStyle-HorizontalAlign="Center"></asp:BoundField>    
                 <asp:BoundField DataField="fecVencimiento" HeaderText="Fec. Vencimiento." DataFormatString="{0:dd/MM/yyyy}"  HtmlEncode="False" 
                  HeaderStyle-Width="200" ItemStyle-HorizontalAlign="Center" >
                    <HeaderStyle Width="200px" />
                 </asp:BoundField>
                 <asp:BoundField DataField="emplazamiento" HeaderText="Emplazamiento"  HeaderStyle-Width="250" ItemStyle-HorizontalAlign="Center" >
                    <HeaderStyle Width="250px" /></asp:BoundField> 
                 <asp:BoundField DataField="fecNacionalizacion" HeaderText="Fec. Nacio." DataFormatString="{0:dd/MM/yyyy}"  HtmlEncode="False" ItemStyle-HorizontalAlign="Center">
                 </asp:BoundField>
                 <asp:BoundField DataField="codstatus" Visible="false"></asp:BoundField> 
                 <asp:BoundField DataField="status" HeaderText="Status" ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="chasis" HeaderText="Chasis" ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="motor" HeaderText="Motor" ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="caja" HeaderText="Caja" ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="pedidoImportacion" HeaderText="Pedido Imp." ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="marca" HeaderText="Marca" ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="modelo" HeaderText="Modelo" ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
                 <asp:BoundField DataField="grupoArticulo" HeaderText="Grupo Artículo" ItemStyle-HorizontalAlign="Center"></asp:BoundField>                                               
            </Columns>                        
             <HeaderStyle BackColor="Silver" />
            <BoundaryStyle BorderColor="Gray" BorderStyle="Solid" BorderWidth="1px" />
      </cc2:CoolGridView>      
        
    </div>

<!-- Modal para la reserva de stock -->


<asp:Panel ID="pnlReserva" runat="server" ScrollBars="Auto" Width="750px" CssClass="modalPopup" style="display:none">
    <asp:Panel ID="pnlMoveReserva" runat="server" Width="100%" BackColor="lightblue" BorderColor="#6289AE" HorizontalAlign="Center">
             <asp:Label ID="lblTituloReserva" runat="server" Text="Reserva" Width="100%" />
    </asp:Panel>   
          
    <asp:UpdatePanel ID="upReserva" runat="server">
        <ContentTemplate>    
            <br />
            <table>
                <tr>
                    <td>Cliente:</td>
                    <td>
                        <asp:TextBox ID="txtCodCliente" runat="server" CssClass="inputbox" MaxLength="10" 
                            AutoCompleteType="Company" Width="80px" AutoPostBack="True" OnTextChanged="txtCodCliente_TextChanged" />
                        <asp:FilteredTextBoxExtender ID="ftbeCodCliente" runat="server" TargetControlID="txtCodCliente" FilterType="Numbers" Enabled="True" />     
                    </td>
                    <td>
                       <asp:TextBox ID="txtNomCliente" runat="server" CssClass="inputbox" AutoCompleteType="Disabled" Width="200px" AutoPostBack="True" />
                       <asp:AutoCompleteExtender ID="aceNomCliente" runat="server" TargetControlID="txtNomCliente" MinimumPrefixLength="1" 
                          CompletionInterval="100" CompletionSetCount="15" CompletionListCssClass="autocomplete_completionListElement" 
                          CompletionListItemCssClass="autocomplete_listItem"
                          CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" DelimiterCharacters="" ServiceMethod="buscaClientes"
                          OnClientItemSelected="getCodigo" Enabled="True" ServicePath="">
                       </asp:AutoCompleteExtender>   
                    </td
                </tr>    
            </table> 
            
            <table style="width:360px; text-align:right; float:right">
                <tr>
                    <td> Válido de :</td>
                    <td>
                        <asp:TextBox ID="txtFechaDesde" runat="server"  Width="80px" Enabled="false"></asp:TextBox>
                    </td>
                    <td> Válido a  :</td>
                    <td>
                        <asp:TextBox ID="txtFechaHasta" runat="server" Width="80px" Enabled="false"></asp:TextBox>
                    </td>
                </tr>
            </table>      
            <br style="clear:both" />
            <div style="float:right">
                  <asp:Button ID="btnQuitarReserva" runat="server" Text="Quitar" onclick="btnQuitarReserva_Click" />             
            </div>
            <div style="clear:both"></div>
            <asp:Panel ID="pnlReservaList" runat="server" Width="100%" Height="290px" 
                  EnableViewState="true" ScrollBars="Auto">
            <asp:GridView ID="gvReserva" runat="server" CssClass="tbl-stock" Width="100%" AutoGenerateColumns="false" 
                 ShowFooter="true">
                <Columns>                    
                     <asp:BoundField DataField="lote" HeaderText="Lote"></asp:BoundField> 
                     <asp:BoundField DataField="codMaterial" HeaderText="Material"></asp:BoundField> 
                     <asp:BoundField DataField="descMaterial" HeaderText="Descripción"></asp:BoundField>                 
                     <asp:BoundField DataField="descColor" HeaderText="Color"></asp:BoundField>                            
                     <asp:TemplateField HeaderText="">
                         <itemtemplate>
                             <asp:CheckBox ID="cbSelect" runat="server" />
                             <asp:Label id="lblCodigo" Visible="false" runat="server" Text='<%# Bind("CodMaterial") %>'></asp:Label>
                             <asp:Label id="lblLote" Visible="false" runat="server" Text='<%# Bind("lote") %>'></asp:Label>
                              <asp:Label id="lblStatus" Visible="false" runat="server" Text='<%# Bind("codstatus") %>'></asp:Label>
                          </itemtemplate>       
                     </asp:TemplateField>                                  
                </Columns>                        
            </asp:GridView>    
            </asp:Panel>

            <br style="clear:both" />
            <div style="width:100%; text-align:right; padding-top:5px;">
                <asp:ImageButton ID="btnReservar" runat="server" ImageUrl="~/img/ok16.png" 
                    ImageAlign="Middle" onclick="btnReservar_Click"  />
                <asp:ImageButton ID="btnCloseReserva" OnClientClick="CerrarDialogo();" runat="server" ImageUrl="~/img/cancel16.png" ImageAlign="Middle" />
            </div>

            <div style="clear:both"></div>
        </ContentTemplate>
    </asp:UpdatePanel>
    
</asp:Panel>

 <asp:HiddenField ID="hfReserva" runat="server" />
 <asp:ModalPopupExtender ID="mpeReserva" runat="server" TargetControlID="hfReserva" BehaviorID="mpeReserva"
        PopupControlID="pnlReserva"  BackgroundCssClass="modalBackground" 
        PopupDragHandleControlID="pnlMoveReserva" >
</asp:ModalPopupExtender>


<!-- Fin de Modal -->


<!-- Inicio modal asignación de campañas -->

<asp:Panel ID="pnlCampania" runat="server" ScrollBars="Auto" Width="750px" CssClass="modalPopup" style="display:none">
    <asp:Panel ID="pnlMoveCampania" runat="server" Width="100%" BackColor="lightblue" BorderColor="#6289AE" HorizontalAlign="Center">
             <asp:Label ID="lblTituloCampania" runat="server" Text="Asignación de Campaña" Width="100%" />
    </asp:Panel>   
          
    <asp:UpdatePanel ID="upCampania" runat="server">
        <ContentTemplate>   
            <table style="width:100%;">
                <tr>
                    <td> Campañas: </td>
                    <td>
                        <asp:DropDownList ID="ddlTipo" runat="server">
                            <asp:ListItem Text="-Seleccione-" Value=""></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
            </table>      
            <br style="clear:both" />
            <div style="float:right">
                  <asp:Button ID="btnQuitarCampania" runat="server" Text="Quitar" onclick="btnQuitarCampania_Click" />             
            </div>
            <div style="clear:both"></div>
            <asp:Panel ID="pnlCampaniaList" runat="server" Width="100%" Height="290px" 
                  EnableViewState="true" ScrollBars="Auto">
            <asp:GridView ID="gvCampania" runat="server" CssClass="tbl-stock" Width="100%" AutoGenerateColumns="false" 
                 ShowFooter="true">
                <Columns>                    
                     <asp:BoundField DataField="lote" HeaderText="Lote"></asp:BoundField> 
                     <asp:BoundField DataField="codMaterial" HeaderText="Material"></asp:BoundField> 
                     <asp:BoundField DataField="descMaterial" HeaderText="Descripción"></asp:BoundField>                 
                     <asp:BoundField DataField="descColor" HeaderText="Color"></asp:BoundField>                            
                     <asp:TemplateField HeaderText="">
                         <itemtemplate>
                             <asp:CheckBox ID="cbSelect" runat="server" />
                             <asp:Label id="lblCodigo" Visible="false" runat="server" Text='<%# Bind("CodMaterial") %>'></asp:Label>
                             <asp:Label id="lblLote" Visible="false" runat="server" Text='<%# Bind("lote") %>'></asp:Label>
                             <asp:Label id="lblStatus" Visible="false" runat="server" Text='<%# Bind("codstatus") %>'></asp:Label>
                          </itemtemplate>       
                     </asp:TemplateField>                                  
                </Columns>                        
            </asp:GridView>    
            </asp:Panel>

            <br style="clear:both" />
            <div style="width:100%; text-align:right; padding-top:5px;">
                <asp:ImageButton ID="btnAsignarCampania" runat="server" ImageUrl="~/img/ok16.png" 
                    ImageAlign="Middle" onclick="btnAsignarCampania_Click"  />
                <asp:ImageButton ID="btnCancelarCampania" OnClientClick="CerrarDialogoCampania();" runat="server" ImageUrl="~/img/cancel16.png" ImageAlign="Middle" />
            </div>

            <div style="clear:both"></div>
        </ContentTemplate>
    </asp:UpdatePanel>
    
</asp:Panel>

 <asp:HiddenField ID="hfCampania" runat="server" />
 <asp:ModalPopupExtender ID="mpeCampania" runat="server" TargetControlID="hfCampania" BehaviorID="mpeCampania"
        PopupControlID="pnlCampania"  BackgroundCssClass="modalBackground" 
        PopupDragHandleControlID="pnlMoveCampania" >
</asp:ModalPopupExtender>


<!-- Inicio modal para pedidos -->

<asp:Panel ID="pnlPedido" runat="server" ScrollBars="Auto" Width="750px" CssClass="modalPopup" style="display:none">
    <asp:Panel ID="pnlMovePedido" runat="server" Width="100%" BackColor="lightblue" BorderColor="#6289AE" HorizontalAlign="Center">
             <asp:Label ID="lblTitPedido" runat="server" Text="Creación de Pedido" Width="100%" />
    </asp:Panel>   
          
    <asp:UpdatePanel ID="upPedido" runat="server">
        <ContentTemplate> 

            <table width="auto">
                <tr>
                    <td>
                        <td>
                            Desea crear con referencia:</td>
                        <td>
                            <asp:RadioButtonList ID="rblReferencia" OnSelectedIndexChanged="rblReferencia_SelectedIndexChanged" runat="server" RepeatDirection="Horizontal" AutoPostBack="true">
                                <asp:ListItem Text="Si" Value="S"></asp:ListItem>
                                <asp:ListItem Text="No" Value="N" Selected="True"></asp:ListItem>
                            </asp:RadioButtonList>
                        </td>
                        <td> 
                            <div id="divReferencia" runat="server" visible="false">       
                                Referencia Nro:                   
                                <asp:TextBox ID="txtReferencia" runat="server"></asp:TextBox>
                            </div>                            
                        </td>
                    </td>
                </tr>
            </table>

            <br style="clear:both" />
            <div style="float:right">
                  <asp:Button ID="btnQuitarPedido" runat="server" Text="Quitar" onclick="btnQuitarCampania_Click" />             
            </div>
            <div style="clear:both"></div>
            <asp:Panel ID="pnlPedidoList" runat="server" Width="100%" Height="290px" 
                  EnableViewState="true" ScrollBars="Auto">
            <asp:GridView ID="gvPedidos" runat="server" CssClass="tbl-stock" Width="100%" AutoGenerateColumns="false" 
                 ShowFooter="true">
                <Columns>                    
                     <asp:BoundField DataField="lote" HeaderText="Lote"></asp:BoundField> 
                     <asp:BoundField DataField="codMaterial" HeaderText="Material"></asp:BoundField> 
                     <asp:BoundField DataField="descMaterial" HeaderText="Descripción"></asp:BoundField>                 
                     <asp:BoundField DataField="descColor" HeaderText="Color"></asp:BoundField>                            
                     <asp:TemplateField HeaderText="">
                         <itemtemplate>
                             <asp:CheckBox ID="cbSelect" runat="server" />
                             <asp:Label id="lblCodigo" Visible="false" runat="server" Text='<%# Bind("CodMaterial") %>'></asp:Label>
                             <asp:Label id="lblLote" Visible="false" runat="server" Text='<%# Bind("lote") %>'></asp:Label>
                             <asp:Label id="lblStatus" Visible="false" runat="server" Text='<%# Bind("codstatus") %>'></asp:Label>
                          </itemtemplate>       
                     </asp:TemplateField>                                  
                </Columns>                        
            </asp:GridView>    
            </asp:Panel>

            <br style="clear:both" />
            <div style="width:100%; text-align:right; padding-top:5px;">
                <asp:ImageButton ID="imgAceptarPedido" runat="server" ImageUrl="~/img/ok16.png" 
                    ImageAlign="Middle" onclick="btnAceptarPedido_Click"  />
                <asp:ImageButton ID="imgClosePedido" OnClientClick="CerrarDialogoPedido();" runat="server" ImageUrl="~/img/cancel16.png" ImageAlign="Middle" />
            </div>

            <div style="clear:both"></div>
        </ContentTemplate>
    </asp:UpdatePanel>
    
</asp:Panel>

 <asp:HiddenField ID="hfPedido" runat="server" />
 <asp:ModalPopupExtender ID="mpePedido" runat="server" TargetControlID="hfPedido" BehaviorID="mpePedido"
        PopupControlID="pnlPedido"  BackgroundCssClass="modalBackground" 
        PopupDragHandleControlID="pnlMovePedido" >
</asp:ModalPopupExtender>





</asp:Content>

